package com.itheima.stream;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

public class Demo02 {

    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>(List.of("张三丰", "张三丰", "张无忌", "张翠山", "王二麻子", "张良", "谢广坤"));
       // list.stream().limit(5).forEach(s-> System.out.println(s));
       // list.stream().skip(2).forEach(s -> System.out.println(s));
        //list.stream().distinct().forEach(s-> System.out.println(s));
        /*Stream<String> stream = list.stream().filter(s -> s.startsWith("张"));
        Stream<String> stream1 = stream.distinct();
        stream1.forEach(s-> System.out.println(s));
        stream1.filter(s->s.length()==3).forEach(s-> System.out.println(s));*/
        ArrayList<String> list1 = new ArrayList<>(List.of("坤坤", "签签", "滔滔", "小鹿"));


        Stream<String> stream = list.stream();
        Stream<String> stream1 = list1.stream();

        Stream<String> heStream = Stream.concat(stream, stream1);
        heStream.forEach(s-> System.out.println(s));
        ArrayList<Integer> list2 = new ArrayList<>(List.of(11, 22, 33, 44, 55));
        Stream<Integer> stream2 = list2.stream();
        Stream<String> stream3 = list.stream();
        Stream<?> concat = Stream.concat(stream2, stream3);
        concat.forEach(s-> System.out.println(s));
        //stream.forEach(s-> System.out.println(s));
    }
}
